<template>
	<div class="lm-chatgpt-item">
		<chatgpt-item-header text="正在为您生成结果：任务安排"></chatgpt-item-header>
		<div class="chatgpt-item-content">
			<div class="item-section-title">任务安排</div>
			<common-table ref="commonTable" :tableConfig="tableConfig" :hasPage="false" :border="false"></common-table>
		</div>
	</div>
</template>

<script>
import ChatgptItemHeader from './chatgpt-item-header'
import CommonTable from '@/components/common/common-table.vue'
import { mapState, mapMutations } from "vuex"
export default {
	name: 'OrdinaryTaskManage',
	props: {
		item: Object
	},
	components: {
		ChatgptItemHeader,
		CommonTable
	},
	data() {
		return {
			// 表格配置
			tableConfig: {
				total: 0,
				pageNo: 1,
				pageSize: 10,
				tData: [],
				// tData: [{
				// 	name: '张三',
				// 	remark: '请按照以下要求生成任务安排',
				// 	date: '2022-01-01',
				// 	status: 1
				// },{
				// 	name: '张三',
				// 	remark: '按照以下要求生成任务安排',
				// 	date: '2024-05-03',
				// 	status: 2
				// }],
				tColumns: [
					{
						type: "index",
						width: 50
					},
					{
						title: '关联客户',
						key: 'name',
						width: 88,
						ellipsis: true,
					},
					{
						title: '内容描述',
						key: 'remark',
						minWidth: 88,
						ellipsis: true,
					},
					{
						title: '截止日期',
						key: 'date',
						width: 88,
						render: (h, params) => {
							return h(
								'span',
								{
									class: new Date(params.row.date).getTime() < new Date().getTime() ? 'red' : '',
								},
								params.row.date
							)
						}
					},
					{
						title: '操作',
						key: 'action',
						width: 88,
						className: 'table-opt',
						// fixed: 'right',
						align: 'center',
						render: (h, params) => {
							return h('div', [
								h(
									'span',
									{
										class: `ope-btn`,
										on: {
											click: () => {
												this.updateStatus(params.index, params.row)
											}
										}
									},
									params.row.status == 1 ? '已完成' : '未完成'
								),
							])
						}
					}
				],
			},
		}
	},
	computed: {
		
	},
	methods: {
		updateStatus(index, row) {
			let _str = row.status == 1 ? '是否确定完成了这个任务？' : '是否确定未完成这个任务？'
			this.$hMsgBox.confirm({
				title: _str,
				content: "",
				onOk: () => {
					this.$refs.commonTable.handleModifyData(index, {
						...row,
						status: row.status == 1 ? 2 : 1
					});
				}
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.item-section-title{
	margin-bottom: 18px;
}
/deep/ .red{
	color: #E42222;
}
</style>